Does anyone have a good example/sample of "goto" spaghetti code? [closed]

Posted by ArtB on Programmers See other posts from Programmers or by ArtB
Published on 2012-07-06T14:32:51Z Indexed on 2012/07/06 15:22 UTC
Read the original article Hit count: 253

Filed under:
|

I've read a lot about how GoTo was considered harmful and removed for other control structures that were more intuitive. Does anyone have a good example / sample of goto spaghetti code? Preferrably, the sample code should be difficult to follow, but realtively easy when rewritten into more conventional control structures.

I know I could try to write you some of my own, but I've never really used goto and don't think I could due justice to the headaches its abuse can lead to.

I want this for didactic purposes to train junior developers on what to avoid. Mainly, to point to illustrate how OOP is taking the same idea to next logical consequence.

EDIT: by good example I mean code that is terrible to read and abuses it, rather than code that uses goto for reasonable optimization

© Programmers or respective owner

Related posts about basic

Related posts about goto